<div class="content-section implementation GridDemo" id="myContent" >
    <div class="title col-sm-12">
        <div class="col-sm-1">
            <span>{{formTitle}}</span>
        </div>
        <div class="col-sm-11 pull-right">
            <button type="button"
                    class="pull-right"
                    pButton
                    (click)="goBack()"
                    icon="fa-close"
                    style="width: 30px"></button>
        </div>
    </div>
    <form [formGroup]="myForm" class="form-horizontal">
        <div class="form-group">
            <label class="col-sm-2 control-label">出入单号：</label>
            <div class="col-sm-10 ui-no-padding-left-15px">
                <input type="text" pInputText
                       class="form-control cursor_not_allowed"
                       readonly
                       placeholder="系统自动生成"
                       [value]="formObj.sid"/>
            </div>

        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">申请人：</label>
            <div class="col-sm-4 ui-fluid-no-padding ui-fluid">
                <input type="text"
                       class=" form-control cursor_not_allowed"
                       pInputText
                       [value]="formObj.creator"
                       readonly />
            </div>
            <label class="col-sm-2 control-label">申请人组织：</label>
            <div class="col-sm-4 ui-fluid-no-padding">
                <input type="text"
                       class=" form-control cursor_not_allowed"
                       pInputText
                       [value]="formObj.creator_org"
                       readonly />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">
                <span ngClass="start_red">*</span>
                所属房间：
            </label>
            <div class="col-sm-4 ui-fluid-no-padding">
                <div class="col-sm-6 ui-fluid ui-fluid-no-padding">
                    <input type="text" pInputText
                           placeholder="请选择房间"
                           readonly
                           formControlName="room_name"
                           [(ngModel)]="formObj.room_name"
                           class=" form-control cursor_not_allowed"
                    />
                    <app-field-error-display [displayError]="isFieldValid('room_name')" errorMsg="不能为空"></app-field-error-display>
                </div>
                <div class="col-sm-3 ui-fluid-no-padding ui-padding-10px">
                    <button  ngClass="ui-g-12 ui-fluid-no-padding"  pButton type="button" (click)="showTreeDialog()" label="选择"></button>
                </div>
                <div class="col-sm-3 ui-fluid-no-padding ui-padding-10px">
                    <button  ngClass="ui-g-12 ui-fluid-no-padding"  pButton type="button" (click)="clearTreeDialog()" label="清空"></button>
                </div>
            </div>
            <label class="col-sm-2 control-label">状态：</label>
            <div class="col-sm-4 ui-fluid-no-padding">
                <input type="text"
                    class=" form-control cursor_not_allowed"
                    pInputText
                    [value]="formObj.status"
                       placeholder="新建"
                    readonly />
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-2 control-label">
                <span ngClass="start_red">*</span>
                出入类型：
            </label>
            <div class="col-sm-4 ui-fluid-no-padding ui-fluid">
                <p-dropdown [options]="allTypes"
                            [(ngModel)]="formObj.registration_type"
                            [ngModelOptions]="{standalone: true}"
                            [style]="{'width':'100%'}"
                ></p-dropdown>
            </div>
            <label class="col-sm-2 control-label">
                <span ngClass="start_red">*</span>
                审批人：
            </label>
            <div class="col-sm-4 ui-fluid-no-padding ui-fluid">
                <p-dropdown [options]="allApprovals"
                            [(ngModel)]="formObj.approver"
                            [ngModelOptions]="{standalone: true}"
                            [style]="{'width':'100%'}"
                ></p-dropdown>
            </div>
        </div>
        <div class="form-group" formGroupName="timeGroup">
            <label class="col-sm-2 control-label">
                <span ngClass="start_red">*</span>
                计划出入时间：
            </label>
            <div class="col-sm-4 ui-fluid-no-padding ui-fluid">
                <p-calendar [(ngModel)]="formObj.plan_time_begin"
                            [showIcon]="true"
                            [locale]="zh"
                            [styleClass]="'schedule-add'"
                            dateFormat="yy-mm-dd"
                            [showTime]="true"
                            (onSelect) = "startTimeSelected(formObj.plan_time_begin)"
                            formControlName="plan_time_begin"
                            [showSeconds]="true">
                </p-calendar>
                <!--{{isFieldFroupValid()}}-->
                <!--{{myForm.get('timeGroup').touched}}-->
                <app-field-error-display [displayError]="isFieldFroupValid() && myForm.get('timeGroup').get('plan_time_begin').touched" errorMsg="开始时间不能与结束时间相同"></app-field-error-display>
                <app-field-error-display [displayError]="isFieldGroupItemValid('plan_time_begin')" errorMsg="不能为空"></app-field-error-display>
            </div>
            <label class="col-sm-2 control-label">
                <span ngClass="start_red">*</span>
                至：
            </label>
            <div class="col-sm-4 ui-fluid-no-padding ui-fluid">
                <p-calendar [(ngModel)]="formObj.plan_time_end"
                            [showIcon]="true"
                            [locale]="zh"
                            [styleClass]="'schedule-add'"
                            dateFormat="yy-mm-dd"
                            [showTime]="true"
                            formControlName="plan_time_end"
                            [minDate]="minEndTime"
                            [showSeconds]="true">
                </p-calendar>
                <app-field-error-display [displayError]="isFieldFroupValid() && myForm.get('timeGroup').get('plan_time_end').touched" errorMsg="开始时间不能与结束时间相同"></app-field-error-display>
                <app-field-error-display [displayError]="isFieldGroupItemValid('plan_time_end')" errorMsg="不能为空"></app-field-error-display>
            </div>
        </div>
        <div class="form-group ">
            <label class="col-sm-2 control-label">
                出入原因：</label>
            <div class="col-sm-10 ui-no-padding-left-15px ui-fluid">
                <textarea [rows]="5" pInputTextarea
                          autoResize="autoResize"
                          formControlName="content"
                       [(ngModel)]="formObj.content">
                </textarea>
            </div>
        </div>
        <div class="form-group ">
            <div class="col-sm-12 ui-no-padding-left-15px ">
              <!--<button class="pull-right" pButton type="button"   label="移除设备" (click)="removeEquipmenst()" [disabled]="!isFieldValueValid('room_name')" ></button>-->
              <button class="pull-right" pButton type="button" [disabled]="!isFieldValueValid('room_name')"  label="选择设备" (click)="openEquipList()"></button>
              <button class="pull-right" pButton type="button" [disabled]="!isFieldValueValid('room_name')"  label="录入设备" (click)="showAdd()"></button>
            </div>
        </div>
        <div class="form-group ">
            <div class="col-sm-12 padding-left-2vw">
                <app-unaccess-equip-table #unaccessTable (tableDataEmitter)="tableDataEmitter($event)"></app-unaccess-equip-table>
            </div>
        </div>
        <div class="form-group ">
            <div class="col-sm-12 ui-no-padding-left-15px ">
                <button class="pull-right  ui-button-secondary" pButton type="button"
                        (click)="goBack()" label="取消"></button>
                <button class="pull-right ui-margin-right-10px" pButton type="button" (click)="submit()" label="提交" ></button>
                <button  class="pull-right ui-margin-right-10px" pButton type="button" (click)="save()" label="保存" ></button>
            </div>
        </div>
        <app-access-select-equipments #accessSelectEquip [roomDid]="formObj.room_did"  (selectedEmitter)="selectedEquipsEmitter($event)" [display]="controlDiaglog" (displayEmitter)="dcontrolDialogHandler($event)" ></app-access-select-equipments>
        <app-access-import-equips *ngIf="showAddMask" [roomObj]="roomObj" [state]="state" (closeAddMask)="removeMask($event)" (importedEquip)="importedEquip($event)"></app-access-import-equips>
        <app-capacity-dialog  #capacityDialog [display]="displayCapcity" (dispalyEmitter)="displayCapcityEmitter($event)" (selectedEmitter)="seledtedCapcityEmitter($event)"></app-capacity-dialog>
    </form>
</div>
